const gulp=require("gulp"),
	 sass=require("gulp-sass"),
	 connect=require("gulp-connect")
	 
	 //sass编译
	 gulp.task("sass",function(){
	 	gulp.src("./src/scss/*.scss")
	 		.pipe(sass({outputStyle:"compressed"}))
	 		.pipe(gulp.dest("./src/css"))
	 		.pipe(connect.reload())
	 })
	 
	 //sass复制
	 gulp.task("prod_sass",function(){
	 	gulp.src("./src/scss/*.scss")
	 		.pipe(sass({outputStyle:"compressed"}))
	 		.pipe(gulp.dest("./dist/css"))
	 		.pipe(connect.reload())
	 })
	 
	 //HTML修改刷新
	 gulp.task("html",function(){
	 	gulp.src("./src/**.html")
	 		.pipe(connect.reload())
	 })
	 
	 //HTML复制
	 gulp.task("prod_html",function(){
	 	gulp.src("./src/**.html")
//	 		.pipe(htmlmin())
	 		.pipe(gulp.dest("./dist"))
	 		.pipe(connect.reload())
	 })
	 
	 //js修改刷新
	 gulp.task("js",function(){
	 	gulp.src("./src/js/*.js")
	 		.pipe(connect.reload())
	 })
	 
	 //js复制
	 gulp.task("prod_js",function(){
	 	gulp.src("./src/js/*.js")
//	 		.pipe(uglify)
	 		.pipe("./dist")
	 		.pipe(connect.reload())
	 })
	 
	 //图片复制
	 gulp.task("copy-images",function(){
	 	gulp.src("./src/images/**/*.*")
	 		.pipe(gulp.dest("./dist/images"))
	 });
	 
	 //复制lib
	 gulp.task("copy-lib",function(){
	 	gulp.src("./src/lib/**/*.*")
	 		.pipe(gulp.dest("./dist/lib"));
	 })

	//整合
	gulp.task("prod_copy",["copy-images","copy-lib"]);
	
	 //服务器
	 gulp.task("connect",function(){
	 	connect.server({
	 		root:"src",
	 		livereload:true
	 	})
	 })
	 
	 //watch监听
	 gulp.task("watch",function(){
	 	gulp.watch("./src/scss/*.scss",["sass"]);
	 	gulp.watch("./src/**.html",["html"]);
	 	gulp.watch("./src/js/*.js",["js"])
	 })
	
	//执行
	gulp.task("default",["sass","html","js","connect","watch","prod_sass","prod_html","prod_js","prod_copy","connect","watch"]);
//	gulp.task("production",["prod_sass","prod_html","prod_js","prod_copy","connect","watch"]);
